// ThreadReader.cpp: implementation of the ThreadReader class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "phsshare.h"
#include "ThreadReader.h"
#include "ThreadFunction.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

using namespace PropertySystem;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

ThreadReader::ThreadReader()
{

}

ThreadReader::~ThreadReader()
{

}

FunctionObject* ThreadReader::Reader(const _RecordsetPtr& rs)
{
	FunctionObject* pObject = this->CreateObject(rs);
	
	Variable* pVariable = NULL;

	ASSERT(pObject->IsKindOf(RUNTIME_CLASS_EX(ThreadFunction)));
	if(!pObject->IsKindOf(RUNTIME_CLASS_EX(ThreadFunction)))
	{
		delete pObject;
		return NULL;
	}
	ThreadFunction* pThread = static_cast<ThreadFunction*>(pObject);
	
	pVariable = this->GetVariable(1, rs);
	ASSERT(pVariable);
	pThread->SetDiameter(pVariable);

	pVariable = this->GetVariable(2, rs);
	ASSERT(pVariable);
	pThread->SetLength(pVariable);
	return pThread;
}
